package com.crl.module.npc.action
{
	import com.crl.module.npc.controller.INpcLogic;
	
	
	/**
	 *  调用内部方法action
	 * @author crl;
	 * 
	 */	
	public class CallMethodAction extends AbstractAction
	{		
		public var methodName:String;
		public var params:Array;
		public function CallMethodAction(npc:INpcLogic)
		{
			super(npc);
			this.type="call";
		}
		
		
		override public function parseXML(xml:XML):void{
			var methodName:String=xml.@method;
			var params:String=xml.@params;
			
			var methodParams:Array=[];
			if(params !=""){
				methodParams=params.split("|");
			}
			
			this.methodName=methodName;
			this.params=methodParams;
		}

		override public function execute():void
		{
			try{
				npc[methodName].apply(npc,params);
			}catch(e:Error){
				trace(e.message);
			}
		}
		
	}
}